package com.lhd.action.memento;

/**
 * @Author: liuhd
 * @Date: 2024/12/19 17:10
 * @Description:
 */
public class Client {
    public static void main(String[] args) {
        Caretaker caretaker = new Caretaker();
        UserInfo userInfo = new UserInfo("lhd", "123");
        caretaker.setState(userInfo.saveState());

        System.out.println("state-0--saved");
        System.out.println(userInfo);

        userInfo.setPassword("456");
        System.out.println("state-1--not-saved");
        System.out.println(userInfo);

        userInfo.restoreState(caretaker.getState(0));
        System.out.println("state-0--saved");
        System.out.println(userInfo);
    }
}
